<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>云钢</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <style>
        #aui-footer{ z-index: 9999999; }
        #aui-footer img{ width: 1.2rem; height: 1.2rem; margin: 0 auto; }
        .aui-bar-tab{ color: #666666; }
        .aui-bar-tab .aui-active{ color: #0F92EA; }
        .aui-bar-tab img.on{ display: none; }
        .aui-bar-tab .aui-active img.on{ display: block; }
        .aui-bar-tab .aui-active img.hid{ display: none; }
        #aui-footer img.contericon{ width: 2.7rem; height: auto; margin-top: -1.3rem; }
    </style>
</head>

<body>
    <footer class="aui-bar aui-bar-tab" id="aui-footer">
        <div class="aui-bar-tab-item aui-active" tapmode>
            <img src="../image/bar/homeon.png" class="on">
            <img src="../image/bar/home.png" class="hid">
            <div class="aui-bar-tab-label">首页</div>
        </div>
        <div class="aui-bar-tab-item" tapmode>
            <img src="../image/bar/newson.png" class="on">
            <img src="../image/bar/news.png" class="hid">
            <div class="aui-bar-tab-label">资讯</div>
        </div>
        <div class="aui-bar-tab-item" tapmode>
            <img src="../image/bar/fabu.png" class="contericon">
            <div class="aui-bar-tab-label">发布</div>
        </div>
        <div class="aui-bar-tab-item" tapmode>
            <!-- <div class="aui-dot"></div> -->
            <img src="../image/bar/sendon.png" class="on">
            <img src="../image/bar/send.png" class="hid">
            <div class="aui-bar-tab-label">消息</div>
        </div>
        <div class="aui-bar-tab-item" tapmode>
            <!-- <div class="aui-dot"></div> -->
            <!-- <i class="aui-iconfont aui-icon-my"></i> -->
            <img src="../image/bar/meon.png" class="on">
            <img src="../image/bar/me.png" class="hid">
            <div class="aui-bar-tab-label">我的</div>
        </div>
    </footer>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/aui-tab.js" ></script>
<script type="text/javascript">
    apiready = function() {

        api.setStatusBarStyle({
            style: 'dark'
        })
        console.log($api.getStorage('token'))
        api.ajax({
            url: $api.apiUrl+'token/check',
            method: 'post',
            timeout: 30,
            dataType: 'json',
            returnAll: false,
            data: {
                values: {
                    token: $api.getStorage('token')
                }
            }
        }, function(ret, err){
            // console.log(JSON.stringify(ret))
            if(ret.error_code != 0){
                $api.setStorage('token','');
                $api.setStorage('uid','');
                // api.openWin({
                //     name: 'login',
                //     url: 'login_win.html',
                // })
            }
        })

        var footer_h = $api.offset($api.byId('aui-footer')).h;

        api.openFrameGroup ({
            name: 'footer_group',
            scrollEnabled:false,
            rect:{x:0, y:0, w:'auto', h:api.winHeight - footer_h - 25},
            index:0,
            preload:0,
            frames:
            [{
                name: 'index_win', 
                url: 'index_win.html', 
                bounces:false,
                pageParam:{
                    footer_h: footer_h
                }
            },{
                name: 'news_win', 
                url: 'news_win.html', 
                bounces:false,
                pageParam:{
                    footer_h: footer_h
                }
            },{
                name: 'addinfo_win', 
                url: 'addinfo_win.html', 
                bounces:false,
                pageParam:{
                    footer_h: footer_h
                }
            },{
                name: 'send_win',
                url: 'send_win.html', 
                bounces:false,
                pageParam:{
                    footer_h: footer_h
                }
            },{
                name: 'me_win', 
                url: 'me_win.html', 
                bounces:false,
                pageParam:{
                    footer_h: footer_h
                }
            }]
        }, function(ret, err) {
            console.log(ret)
            if(ret.index != 1){
                api.setFrameGroupAttr({
                    name: 'newsgroup',
                    hidden: true
                });
            }else{
                api.setFrameGroupAttr({
                    name: 'newsgroup',
                    hidden: false
                });
            }
        });

        keyListen();
        function keyListen() {
            api.addEventListener({
                name: 'keyback'
            }, function(ret, err) {
                //双击退出
                api.toast({
                      msg: '再按一次退出应用',
                      duration: 2000,
                      location: 'bottom'
                  });
                  api.addEventListener({
                      name: 'keyback'
                  }, function(ret, err) {
                      if (ret) {
                          exitApp();
                      }
                  });
                  setTimeout(function() {
                      keyListen();
                  }, 3000);
            });
        }

        function exitApp() {
            // api.toLauncher();
            api.closeWidget({
                // id: "",
                retData: {
                    name: 'closeWidget'
                },
                animation: {
                    type: 'flip',
                    subType: 'from_bottom',
                    duration: 500
                },
                silent: true
            })
        }

    }
    var tab = new auiTab({
        element:document.getElementById("aui-footer")
    },function(ret){
        console.log(ret)
        var index = ret.index-1;

        api.setFrameGroupIndex({
            name: 'footer_group',
            index: index
        });
    });
    // function randomSwitchBtn(obj, name, index) {
    //     var footer = $api.byId('aui-footer');
    //     var footerAct = $api.dom(footer, '.aui-bar-tab li.active-warning');
    //     $api.removeCls(footerAct, 'active-warning');
    //     $api.addCls(obj, 'active-warning');
    //     api.setFrameGroupIndex({
    //         name: 'footer_group',
    //         scroll: true,
    //         index: index
    //     });

    // }
</script>

</html>
